package com.heima.comment.controller;

import com.heima.comment.service.ApCommentReplyService;
import com.heima.model.common.dtos.CommentRepayDto;
import com.heima.model.common.dtos.CommentRepayLikeDto;
import com.heima.model.common.dtos.CommentRepaySaveDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 文章评论回复
 */
@RestController
@RequestMapping("/api/v1/comment_repay")
@Slf4j
public class ApCommentReplyController {
    @Autowired
    private ApCommentReplyService commentReplyService;

    /**
     * 保存回复评论
     *
     * @param commentRepaySaveDto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody CommentRepaySaveDto commentRepaySaveDto){
        log.info("保存回复评论：{}",commentRepaySaveDto);
        return commentReplyService.save(commentRepaySaveDto);
    }

    /**
     * 查询评论回复列表
     *
     * @param commentRepayDto
     * @return
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody CommentRepayDto commentRepayDto){
        log.info("查看回复评论列表：{}",commentRepayDto);
        return commentReplyService.load(commentRepayDto);
    }

    /**
     * 点赞 0：点赞 1：取消点赞
     *
     * @param commentRepayLikeDto
     * @return
     */
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentRepayLikeDto commentRepayLikeDto){
        log.info("回复评论点赞为：{}",commentRepayLikeDto);
        return commentReplyService.like(commentRepayLikeDto);
    }
}
